/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.vportal.portlet.vadvman.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import com.vportal.portlet.vadvman.model.AdvItem;
import com.vportal.portlet.vadvman.model.AdvItemModel;
import com.vportal.portlet.vadvman.model.AdvItemSoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * The base model implementation for the AdvItem service. Represents a row in the &quot;AdvItem&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.vportal.portlet.vadvman.model.AdvItemModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link AdvItemImpl}.
 * </p>
 *
 * @author DucNN
 * @see AdvItemImpl
 * @see com.vportal.portlet.vadvman.model.AdvItem
 * @see com.vportal.portlet.vadvman.model.AdvItemModel
 * @generated
 */
@JSON(strict = true)
public class AdvItemModelImpl extends BaseModelImpl<AdvItem>
	implements AdvItemModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a adv item model instance should use the {@link com.vportal.portlet.vadvman.model.AdvItem} interface instead.
	 */
	public static final String TABLE_NAME = "AdvItem";
	public static final Object[][] TABLE_COLUMNS = {
			{ "itemId", Types.BIGINT },
			{ "createDate", Types.TIMESTAMP },
			{ "modifiedDate", Types.TIMESTAMP },
			{ "expriedDate", Types.TIMESTAMP },
			{ "groupId", Types.BIGINT },
			{ "companyId", Types.BIGINT },
			{ "name", Types.VARCHAR },
			{ "description", Types.VARCHAR },
			{ "url", Types.VARCHAR },
			{ "isTargetBlank", Types.BOOLEAN },
			{ "txtMouseOver", Types.VARCHAR },
			{ "folderId", Types.BIGINT },
			{ "status", Types.BOOLEAN },
			{ "typeId", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table AdvItem (itemId LONG not null primary key,createDate DATE null,modifiedDate DATE null,expriedDate DATE null,groupId LONG,companyId LONG,name VARCHAR(500) null,description VARCHAR(1000) null,url VARCHAR(500) null,isTargetBlank BOOLEAN,txtMouseOver VARCHAR(500) null,folderId LONG,status BOOLEAN,typeId LONG)";
	public static final String TABLE_SQL_DROP = "drop table AdvItem";
	public static final String ORDER_BY_JPQL = " ORDER BY advItem.createDate DESC";
	public static final String ORDER_BY_SQL = " ORDER BY AdvItem.createDate DESC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.vportal.portlet.vadvman.model.AdvItem"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.vportal.portlet.vadvman.model.AdvItem"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.vportal.portlet.vadvman.model.AdvItem"),
			true);
	public static long GROUPID_COLUMN_BITMASK = 1L;
	public static long STATUS_COLUMN_BITMASK = 2L;
	public static long TYPEID_COLUMN_BITMASK = 4L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static AdvItem toModel(AdvItemSoap soapModel) {
		AdvItem model = new AdvItemImpl();

		model.setItemId(soapModel.getItemId());
		model.setCreateDate(soapModel.getCreateDate());
		model.setModifiedDate(soapModel.getModifiedDate());
		model.setExpriedDate(soapModel.getExpriedDate());
		model.setGroupId(soapModel.getGroupId());
		model.setCompanyId(soapModel.getCompanyId());
		model.setName(soapModel.getName());
		model.setDescription(soapModel.getDescription());
		model.setUrl(soapModel.getUrl());
		model.setIsTargetBlank(soapModel.getIsTargetBlank());
		model.setTxtMouseOver(soapModel.getTxtMouseOver());
		model.setFolderId(soapModel.getFolderId());
		model.setStatus(soapModel.getStatus());
		model.setTypeId(soapModel.getTypeId());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<AdvItem> toModels(AdvItemSoap[] soapModels) {
		List<AdvItem> models = new ArrayList<AdvItem>(soapModels.length);

		for (AdvItemSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.vportal.portlet.vadvman.model.AdvItem"));

	public AdvItemModelImpl() {
	}

	public long getPrimaryKey() {
		return _itemId;
	}

	public void setPrimaryKey(long primaryKey) {
		setItemId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_itemId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return AdvItem.class;
	}

	public String getModelClassName() {
		return AdvItem.class.getName();
	}

	@JSON
	public long getItemId() {
		return _itemId;
	}

	public void setItemId(long itemId) {
		_itemId = itemId;
	}

	@JSON
	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_columnBitmask = -1L;

		_createDate = createDate;
	}

	@JSON
	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		_modifiedDate = modifiedDate;
	}

	@JSON
	public Date getExpriedDate() {
		return _expriedDate;
	}

	public void setExpriedDate(Date expriedDate) {
		_expriedDate = expriedDate;
	}

	@JSON
	public long getGroupId() {
		return _groupId;
	}

	public void setGroupId(long groupId) {
		_columnBitmask |= GROUPID_COLUMN_BITMASK;

		if (!_setOriginalGroupId) {
			_setOriginalGroupId = true;

			_originalGroupId = _groupId;
		}

		_groupId = groupId;
	}

	public long getOriginalGroupId() {
		return _originalGroupId;
	}

	@JSON
	public long getCompanyId() {
		return _companyId;
	}

	public void setCompanyId(long companyId) {
		_companyId = companyId;
	}

	@JSON
	public String getName() {
		if (_name == null) {
			return StringPool.BLANK;
		}
		else {
			return _name;
		}
	}

	public void setName(String name) {
		_name = name;
	}

	@JSON
	public String getDescription() {
		if (_description == null) {
			return StringPool.BLANK;
		}
		else {
			return _description;
		}
	}

	public void setDescription(String description) {
		_description = description;
	}

	@JSON
	public String getUrl() {
		if (_url == null) {
			return StringPool.BLANK;
		}
		else {
			return _url;
		}
	}

	public void setUrl(String url) {
		_url = url;
	}

	@JSON
	public boolean getIsTargetBlank() {
		return _isTargetBlank;
	}

	public boolean isIsTargetBlank() {
		return _isTargetBlank;
	}

	public void setIsTargetBlank(boolean isTargetBlank) {
		_isTargetBlank = isTargetBlank;
	}

	@JSON
	public String getTxtMouseOver() {
		if (_txtMouseOver == null) {
			return StringPool.BLANK;
		}
		else {
			return _txtMouseOver;
		}
	}

	public void setTxtMouseOver(String txtMouseOver) {
		_txtMouseOver = txtMouseOver;
	}

	@JSON
	public long getFolderId() {
		return _folderId;
	}

	public void setFolderId(long folderId) {
		_folderId = folderId;
	}

	@JSON
	public boolean getStatus() {
		return _status;
	}

	public boolean isStatus() {
		return _status;
	}

	public void setStatus(boolean status) {
		_columnBitmask |= STATUS_COLUMN_BITMASK;

		if (!_setOriginalStatus) {
			_setOriginalStatus = true;

			_originalStatus = _status;
		}

		_status = status;
	}

	public boolean getOriginalStatus() {
		return _originalStatus;
	}

	@JSON
	public long getTypeId() {
		return _typeId;
	}

	public void setTypeId(long typeId) {
		_columnBitmask |= TYPEID_COLUMN_BITMASK;

		if (!_setOriginalTypeId) {
			_setOriginalTypeId = true;

			_originalTypeId = _typeId;
		}

		_typeId = typeId;
	}

	public long getOriginalTypeId() {
		return _originalTypeId;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public AdvItem toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (AdvItem)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
					AdvItem.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		AdvItemImpl advItemImpl = new AdvItemImpl();

		advItemImpl.setItemId(getItemId());
		advItemImpl.setCreateDate(getCreateDate());
		advItemImpl.setModifiedDate(getModifiedDate());
		advItemImpl.setExpriedDate(getExpriedDate());
		advItemImpl.setGroupId(getGroupId());
		advItemImpl.setCompanyId(getCompanyId());
		advItemImpl.setName(getName());
		advItemImpl.setDescription(getDescription());
		advItemImpl.setUrl(getUrl());
		advItemImpl.setIsTargetBlank(getIsTargetBlank());
		advItemImpl.setTxtMouseOver(getTxtMouseOver());
		advItemImpl.setFolderId(getFolderId());
		advItemImpl.setStatus(getStatus());
		advItemImpl.setTypeId(getTypeId());

		advItemImpl.resetOriginalValues();

		return advItemImpl;
	}

	public int compareTo(AdvItem advItem) {
		int value = 0;

		value = DateUtil.compareTo(getCreateDate(), advItem.getCreateDate());

		value = value * -1;

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		AdvItem advItem = null;

		try {
			advItem = (AdvItem)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = advItem.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		AdvItemModelImpl advItemModelImpl = this;

		advItemModelImpl._originalGroupId = advItemModelImpl._groupId;

		advItemModelImpl._setOriginalGroupId = false;

		advItemModelImpl._originalStatus = advItemModelImpl._status;

		advItemModelImpl._setOriginalStatus = false;

		advItemModelImpl._originalTypeId = advItemModelImpl._typeId;

		advItemModelImpl._setOriginalTypeId = false;

		advItemModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<AdvItem> toCacheModel() {
		AdvItemCacheModel advItemCacheModel = new AdvItemCacheModel();

		advItemCacheModel.itemId = getItemId();

		Date createDate = getCreateDate();

		if (createDate != null) {
			advItemCacheModel.createDate = createDate.getTime();
		}
		else {
			advItemCacheModel.createDate = Long.MIN_VALUE;
		}

		Date modifiedDate = getModifiedDate();

		if (modifiedDate != null) {
			advItemCacheModel.modifiedDate = modifiedDate.getTime();
		}
		else {
			advItemCacheModel.modifiedDate = Long.MIN_VALUE;
		}

		Date expriedDate = getExpriedDate();

		if (expriedDate != null) {
			advItemCacheModel.expriedDate = expriedDate.getTime();
		}
		else {
			advItemCacheModel.expriedDate = Long.MIN_VALUE;
		}

		advItemCacheModel.groupId = getGroupId();

		advItemCacheModel.companyId = getCompanyId();

		advItemCacheModel.name = getName();

		String name = advItemCacheModel.name;

		if ((name != null) && (name.length() == 0)) {
			advItemCacheModel.name = null;
		}

		advItemCacheModel.description = getDescription();

		String description = advItemCacheModel.description;

		if ((description != null) && (description.length() == 0)) {
			advItemCacheModel.description = null;
		}

		advItemCacheModel.url = getUrl();

		String url = advItemCacheModel.url;

		if ((url != null) && (url.length() == 0)) {
			advItemCacheModel.url = null;
		}

		advItemCacheModel.isTargetBlank = getIsTargetBlank();

		advItemCacheModel.txtMouseOver = getTxtMouseOver();

		String txtMouseOver = advItemCacheModel.txtMouseOver;

		if ((txtMouseOver != null) && (txtMouseOver.length() == 0)) {
			advItemCacheModel.txtMouseOver = null;
		}

		advItemCacheModel.folderId = getFolderId();

		advItemCacheModel.status = getStatus();

		advItemCacheModel.typeId = getTypeId();

		return advItemCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(29);

		sb.append("{itemId=");
		sb.append(getItemId());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append(", expriedDate=");
		sb.append(getExpriedDate());
		sb.append(", groupId=");
		sb.append(getGroupId());
		sb.append(", companyId=");
		sb.append(getCompanyId());
		sb.append(", name=");
		sb.append(getName());
		sb.append(", description=");
		sb.append(getDescription());
		sb.append(", url=");
		sb.append(getUrl());
		sb.append(", isTargetBlank=");
		sb.append(getIsTargetBlank());
		sb.append(", txtMouseOver=");
		sb.append(getTxtMouseOver());
		sb.append(", folderId=");
		sb.append(getFolderId());
		sb.append(", status=");
		sb.append(getStatus());
		sb.append(", typeId=");
		sb.append(getTypeId());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(46);

		sb.append("<model><model-name>");
		sb.append("com.vportal.portlet.vadvman.model.AdvItem");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>itemId</column-name><column-value><![CDATA[");
		sb.append(getItemId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>expriedDate</column-name><column-value><![CDATA[");
		sb.append(getExpriedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>groupId</column-name><column-value><![CDATA[");
		sb.append(getGroupId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>companyId</column-name><column-value><![CDATA[");
		sb.append(getCompanyId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>name</column-name><column-value><![CDATA[");
		sb.append(getName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>description</column-name><column-value><![CDATA[");
		sb.append(getDescription());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>url</column-name><column-value><![CDATA[");
		sb.append(getUrl());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>isTargetBlank</column-name><column-value><![CDATA[");
		sb.append(getIsTargetBlank());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>txtMouseOver</column-name><column-value><![CDATA[");
		sb.append(getTxtMouseOver());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>folderId</column-name><column-value><![CDATA[");
		sb.append(getFolderId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>status</column-name><column-value><![CDATA[");
		sb.append(getStatus());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>typeId</column-name><column-value><![CDATA[");
		sb.append(getTypeId());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = AdvItem.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			AdvItem.class
		};
	private long _itemId;
	private Date _createDate;
	private Date _modifiedDate;
	private Date _expriedDate;
	private long _groupId;
	private long _originalGroupId;
	private boolean _setOriginalGroupId;
	private long _companyId;
	private String _name;
	private String _description;
	private String _url;
	private boolean _isTargetBlank;
	private String _txtMouseOver;
	private long _folderId;
	private boolean _status;
	private boolean _originalStatus;
	private boolean _setOriginalStatus;
	private long _typeId;
	private long _originalTypeId;
	private boolean _setOriginalTypeId;
	private transient ExpandoBridge _expandoBridge;
	private long _columnBitmask;
	private AdvItem _escapedModelProxy;
}